<#-- 分页（Pager对象、链接URL、参数Map、最大页码显示数） -->
<#macro pager pager baseUrl formMethod="POST" parameterMap = {} maxShowPageCount = 6>

	<#local totalCount = pager.totalCount />
	<#local pageNumber = pager.pageNumber />
	
	<#if (pager.pageSize > 0)>
		<#local pageSize = pager.pageSize />
	<#elseif maxShowPageCount??>
		<#local pageSize = maxShowPageCount />
	<#else>
		<#local pageSize = 10 />
	</#if>
	<#if totalCount%pageSize != 0>
		<#local totalPage = (totalCount/pageSize)?int+1 />
	<#else>
		<#local totalPage = (totalCount/pageSize)?int />
	</#if>

	<#if (totalCount >0)>
	<script type="text/javascript">
			function changeUrl(obj){
				var total = '${(totalPage)?c}';
				if(obj.value && obj.value > total){
					obj.value = total;	
				}
				$("#pageNumber").val(obj.value);
			}
			
			function toPager(num){
				if(num){
					$("#pageNumber").val(num);
				}
				$("#pagerForm").submit();
			}
			
			//限制输入框只能输入数字
			function validateNumbers(event){
				var keynum;
				var keychar;
				var numcheck;
				
				if(window.event){// IE
				  keynum = event.keyCode;
				}else if(event.which){// Netscape/Firefox/Opera
				  keynum = event.which;
				}
				if(keynum == 8 || keynum == 46){
					if(event.target.value.length == 1 || (document.selection && document.selection.createRange().text.length == event.target.value.length)
							|| event.target.value.substring(event.target.selectionStart,event.target.selectionEnd).length == event.target.value.length){
						return false;
					}else{
						return true;
					}
				}
				if(keynum == 37 || keynum == 39 || (keynum >= 96 && keynum <= 105)){
					return true;
				}
				keychar = String.fromCharCode(keynum)
				numcheck = /\d/;
				return numcheck.test(keychar);
			}
		</script>
		<form id="pagerForm" action="${basePath}${baseUrl}" method="${formMethod}">
			<input type="hidden" name="pageSize" value="${(pageSize)!'5'}"/>
			<input type="hidden" id="pageNumber" name="pageNumber" value="${(pageNumber)!'1'}"/>
			<input type="hidden" name="property" value="${(pager.property)!''}"/>
			<input type="hidden" name="keyword" value="${(pager.keyword)!''}"/>
			<input type="hidden" name="orderBy" value="${(pager.orderBy)!''}"/>
			<input type="hidden" name="orderType" value="${(pager.orderType)!''}"/>
			<#list parameterMap?keys as key>
				<#if parameterMap[key]??>
					<input type="hidden" name="${key}" value="${(parameterMap[key])!''}"/>
				</#if>
			</#list>
		</form>
	
	
		   <div class="Pagination">
		   <#if pageNumber ==1>
		  	 <a href="javascript:void(0);" class="tips" title="首页">首页</a>
		  	 <a href="javascript:void(0);" class="tips" title="上一页">上一页</a> 
		   	 <#else>
		   	 <a href="javascript:toPager(1);">首页</a>
		   	 <a href="javascript:toPager(${(pageNumber-1)?c});" class="tips" title="上一页">上一页</a> 
		   </#if>  
			<#if (totalPage <= 5)>
				<#list 1 .. totalPage as index>
					<#if pageNumber = index>
						<a href="javascript:void(0);" class="current">${(index)?c}</a>
					<#else>
						<a href="javascript:toPager(${(index)?c});">${(index)?c}</a>
					</#if>
				</#list>
			<#else>
				<#if (pageNumber < 4)>
					<#list 1 .. 4 as index>
						<#if pageNumber = index>
							<a href="javascript:void(0);" class="current">${(index)?c}</a>
						<#else>
							<a href="javascript:toPager(${(index)?c});">${(index)?c}</a>
						</#if>
					</#list>
					<span class="dot">..</span> 
					<a href="javascript:toPager(${(totalPage)?c});">${(totalPage)?c}</a>
				<#else>
					<#if (pageNumber <= totalPage - 3)>
						<a href="javascript:toPager(1);">1</a>
						<span class="dot">..</span> 
						<a href="javascript:toPager(${(pageNumber - 1)?c});">${(pageNumber - 1)?c}</a>
						<a href="javascript:void(0);" class="current">${(pageNumber)?c}</a>
						<a href="javascript:toPager(${(pageNumber + 1)?c});">${(pageNumber + 1)?c}</a>
						<span class="dot">..</span> 
						<a href="javascript:toPager(${(totalPage)?c});">${(totalPage)?c}</a>
					<#else>
						<a href="javascript:toPager(1);">1</a>
						<span class="dot">..</span>  
						<#list 3 .. 0 as index>
							<#if pageNumber = totalPage - index>
								<a href="javascript:void(0);" class="current">${(pageNumber)?c}</a>
							<#else>
								<a href="javascript:toPager(${(totalPage - index)?c});">${(totalPage - index)?c}</a>
							</#if>
						</#list>
					</#if>
				</#if>
			</#if>
			 <#if pageNumber == totalPage>
		   	 <a href="javascript:void(0);" class="tips" title="下一页">下一页</a> 
			 <a href="javascript:void(0);" class="tips" title="末页">末页</a>  
		   	<#else>
		   	 <a href="javascript:toPager(${(pageNumber+1)?c});" class="tips" title="下一页">下一页</a> 
			 <a href="javascript:toPager(${(totalPage)?c});" class="tips" title="末页">末页</a>  
		   </#if> 
			</div>
			<#else>
			<div class="Pagination"></div>
			<form id="pagerForm" action="${basePath}${baseUrl}" method="${formMethod}">
			<input type="hidden" name="pageSize" value="${(pageSize)!'5'}"/>
			<input type="hidden" id="pageNumber" name="pageNumber" value="${(pageNumber)!'1'}"/>
			<input type="hidden" name="property" value="${(pager.property)!''}"/>
			<input type="hidden" name="keyword" value="${(pager.keyword)!''}"/>
			<input type="hidden" name="orderBy" value="${(pager.orderBy)!''}"/>
			<input type="hidden" name="orderType" value="${(pager.orderType)!''}"/>
			<#list parameterMap?keys as key>
				<#if parameterMap[key]??>
					<input type="hidden" name="${key}" value="${(parameterMap[key])!''}"/>
				</#if>
			</#list>
		</form>
   </#if>
   	
</#macro>
